2.10.2 Unary operators

Unary operators have one operand, but three notations: prefix, postfix and bifix. With the first two notations, an operator symbol comes before or after the operand. With bifix notation, the operand comes between two operator symbols. Figure 2.53 summarizes the unary operators. Operands of unary operators can be complex expressions whose expression type is one of real, complex, radial, vector, tuple, set or matrix.

NameSymbolNotationResult.ɽƈʋʂʈɱɗ
Angleprefix.
Cardinality#prefix.
Cardinality##prefix.
Cast. ⅈ ɽ ƈ ʋ ʈ ʂ ɱpostfix
Ceiling⌈ and ⌉bifixo
CofactorCpostfixɱ
Complement¬prefixo
Conjugate¬prefix
Degree°postfix.
DeterminantDpostfix.
Factorial!postfix.
Floor⌊ and ⌋bifixo
GaussGpostfixm
Identity+prefixo
Inverse^-1postfixɱ
JordanJpostfixm
Magnitude| and |bifixo
Max⌈ and ⌉bifixo
Min⌊ and ⌋bifixo
Nablaprefixʋ
Negation-prefix.
ParametricPpostfixt
Partition↑, ↓prefixo
Plus or Minus±prefixo
Precedence( and )bifixo
Sqrtprefix.
Transcendentalssin, etc.prefix.
TransposeTpostfixƈʋɱɱ
Figure 2.53 Unary Operators

Angle extracts the angle from a radial value. If applied to a vector, this operator converts the vector to a radial value and extracts the angle. The angle operator can be decorated with an integer non-negative subscript to extract other than the first angle from multi-dimensional vectors. For example, if rɽ→(a, b, c)ɽ, ∠rɽ is b and ∠_1 rɽ is c.

Cardinality produces the number of items in a collection. The cardinality of a generator produces a real value only if the generator is iterable.

There are some special cases. The cardinality of a real is always 0. The number of columns in a matrix can be found using the ## form of the operator. Examples: #[(, 1), (, 2)] produces 2; ##[(, 1), (, 2)] produces 1.

Cast changes the type of an expression and converts its operand (the source) to a value (the destination) compatible with the type specified by the cast operator (the destination type). For composite and collection operands, the source supplies a sequence of expressions which are imported into the destination value. For composite destination types, the source must supply a sequence of scalars; this is implied for composites and conditional for collections. If the source is a radial, it is first converted to a vector using the magnitude and angle(s).

If the destination is a radial, the sequence is converted to magnitude and angle(s). Conversion to radial only works for sequences of 2 or 3 expressions.

If the source is a matrix, it can be reshaped by casting it to a tuple and using the ↑ operator; [(, 2), (, 1)]ʈ↑(1, 2) simplifies to [(2, 1)]

If the destination is a string, the parsable representation of the source is produced as the value of the string. If the source is a string, it is parsed and the resulting expression is cast to the destination type.

Ceiling. For real operands, finds the nearest integer that is larger than its non-integer operand. For collections, extracts the real with maximum value. For vectors, applies the ceiling operator to each element. Does not apply to complex and radial values, but can be restructured across components of such values.

Cofactor produces the cofactor matrix for a matrix.

Complement changes the value of its operand in the Boolean sense: zero becomes 1 and all other values become zero. The result is displayed as Boolean.

Conjugate restructures a complex number by negating the imaginary part.

Degree converts a real value to radians.

Determinant restructures a square matrix into a real expression representing the determinant of the matrix.

Factorial summarizes a product of integers.

Floor. For real operands, finds the nearest integer that is smaller than its non-integer operands. For collections, extracts the real with minimum value. For vectors, applies the floor operator to each element.

Gauss performs Gaussian elimination on a matrix leaving it in row-echelon form. See also Jordan.

Identity leaves its operand unchanged in sign. Provided for completeness, for use where positivity must be emphasized in contrast to negation.

Inverse inverts a matrix. The matrix must be iterable and contain evaluable items.

Magnitude Finds the magnitude of a value using the Pythagorean rule. Does not apply to matrices.

Jordan performs Gauss-Jordan elimination on a matrix leaving it in reduced-echelon form. See also Gauss.

Max finds the maximum value in a collection. The input form allows a closing parenthesis in place of a closing half-bracket.

Min finds the minimum value in a collection. The input form allows a closing parenthesis in place of a closing half-bracket.

Nabla creates a vector of partial derivatives from a multi-variable real expression.

Negation changes the sign of a value so that, for example, a-b=a+-b.

Not changes a Boolean value so ¬x=if(x=⊤→⊥, x=⊥→⊤).

Plus or Minus provides a shorthand notation for a set of two real values, each the same in magnitude and opposite in sign.

Parametric transforms a matrix to row-echelon form and then transforms the result to a tuple of vectors representing the solution to a system of linear equations in parametric form.

Partition operators ↑ and ↓ behave like their binary counterparts with the right operand implied to be (, 1). ↑ produces the first element of a tuple, the first row of a matrix, or the first character of a string. ↓ removes the first element of a tuple, the first row of a matrix, or the first character of a string.

Precedence causes the operators that make up the operand to bind more closely than the operators of which the precedence operator is an operand.

Square Root provides a short hand notation for binary x^.[1/2].

Transcendentals. The transcendental natural log (ln), base-10 log (log), trigonometric and inverse trigonometric functions are written as prefix unary operators.

Transpose restructures a matrix by exchanging rows or columns. Restructures a tuple by using its items to create a column matrix. The matrix or tuple must be iterable. Transpose also converts between row and column vectors.